<!doctype html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport"
        content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>js正则表达式之转义符</title>
</head>
<body>
  <ul>
    <li>可使用反斜杠(\)对特殊字符(如.,-,\,/等)转义，如在RegExp中定义还需要加反斜杠(\\)进行转义</li>
    <li>点(.)不转义代表除换行外的任意字符，转义(\.)代表普通的小数点</li>
  </ul>
  <script>
    // 转义符(未做边界控制)
    console.log(/\d+\.\d+/.test(12.34))   // true
    const reg1 = new RegExp('\\d+\\.\\d+', 'g')
    console.log(reg1.test(12.34))         // true
    // 检测网址
    const web = 'https://github.com/miracle-git'
    const reg2 = /https?:\/\/\w+\.\w+(\/\w+)?/
    console.log(reg2.test(web))            // true
  </script>
</body>
</html>